<?php
class Asset_Model_Label extends WOW_Model_Acl_Abstract
{
    public function getResourceId()
    {
        return 'Label';
    }

    public function getLabelById($id)
    {
        $id = (int) $id;
        return $this->getResource('Label')->getLabelById($id);
    }

    public function getAllLabels()
    {
        return $this->getResource('Label')->getAllLabels();
    }

    public function getLabelByParentCategoryId($catid)
    {
        return $this->getResource('Label')->getLabelByParentCategoryId($catid);
    }

    public function getLabelByParentSubcatId($subcatid)
    {
        return $this->getResource('Label')->getLabelByParentSubcatId($subcatid);
    }

    public function getParentSubCategory($labelid=null)
    {
        return $this->getResource('Label')->getParentSubCategory($labelid);
    }

    public function getParentCategory($labelid=null)
    {
        return $this->getResource('Label')->getParentCategory($labelid);
    }

    public function getAllLabelArray()
    {
        $all_label  = $this->getResource('Label')->getAllLabels();
        $ret_ar = array(' ' => 'Select Subcategory Label');
        foreach($all_label as $label)
        {
            $ret_ar[$label->labelid] = array('labelname'=>$label->LabelName,'subcategoryid'=>$label->subcatid);
        }

        return $ret_ar;
    }



    

     #@ TODO:: needs to be worked on ACL later
    public function setAcl(WOW_Acl_Interface $acl)
    {
        if (!$acl->has($this->getResourceId()))
        {
            $acl->add($this)->allow('Normal', $this, array('register'))
            ->allow('Moderator', $this, array('saveCategory'))
                    ->allow('Admin', $this);
        }
        $this->_acl = $acl;
        return $this;
    }

    public function getAcl()
    {
        if (null === $this->_acl) {
            $this->setAcl(new Main_Model_Acl_Main());
        }
        return $this->_acl;
    }
}
?>